#%RAML 1.0
title: Inventory API
version: v10.6
protocols: [ HTTP, HTTPS ]
baseUri: http://localhost

documentation:
  - title: "Inventory API"
    content: <b>API for interacting with an inventory of physical resources</b>

types:
  errors: !include raml-util/schemas/errors.schema
  item: !include item.json
  items: !include items.json
  instance: !include instance.json
  instances: !include instances.json
  context: !include instance-context.json
  ingest-status: !include ingest-status.json

traits:
  language: !include raml-util/traits/language.raml
  pageable: !include raml-util/traits/pageable.raml
  searchable: !include raml-util/traits/searchable.raml
  validate: !include raml-util/traits/validation.raml

resourceTypes:
  collection: !include raml-util/rtypes/collection.raml
  collection-item: !include raml-util/rtypes/item-collection.raml

/inventory:
  /items:
    displayName: Items
    type:
      collection:
        exampleCollection: !include examples/items_get.json
        schemaCollection: items
        schemaItem: item
        exampleItem: !include examples/item_get.json
    get:
      is: [pageable,
          searchable: {description: "using CQL (indexes for item and material type)",
            example: "barcode==\"65345656554\""}
          ]
    post:
    delete:
      responses:
        204:
          description: "All items deleted"
    /{itemId}:
      type:
        collection-item:
          exampleItem: !include examples/item_get.json
          schema: item
      get:
      /mark-withdrawn:
        post:
          responses:
            201:
              description: "Item has marked as withdrawn"
              body:
                application/json:
                  example: !include examples/item_get.json
                  schema: item
            404:
              description: "Item not found"
              body:
                text/plain:
                  example: "Item with such id not found"
            422:
              description: "Validation error"
              body:
                application/json:
                  schema: errors
            500:
              description: "Internal server error"
              body:
                text/plain:
                  example: "Internal server error"
      /mark-missing:
        post:
          responses:
            201:
              description: "Item has marked as missing"
              body:
                application/json:
                  example: !include examples/item_get.json
                  schema: item
            404:
              description: "Item not found"
              body:
                text/plain:
                  example: "Item with such id not found"
            422:
              description: "Validation error"
              body:
                application/json:
                  schema: errors
            500:
              description: "Internal server error"
              body:
                text/plain:
                  example: "Internal server error"
  /instances:
    displayName: Instances
    type:
      collection:
        exampleCollection: !include  examples/instances_get.json
        schemaCollection: instances
        schemaItem: instance
        exampleItem: !include examples/instance_get.json
    get:
      is: [pageable,
          searchable: {description: "using CQL (indexes for item and material type)",
            example: "title=\"uproot*\""}
          ]
    post:
      is: [validate]
    delete:
      responses:
        204:
          description: "All instances deleted"
    /{instanceId}:
      type:
        collection-item:
          exampleItem: !include examples/instance_get.json
          schema: instance
      get:
      put:
        is: [validate]
    /context:
      get:
        description: "Provides Dublin Core context for instances"
        responses:
          200:
            description: "Dublin Core context for instances"
            body:
              application/json:
                example: !include examples/instance_context_get.json
                schema: context
  /ingest:
    /mods:
      post:
        body:
          multipart/form-data:
            properties:
              file:
                description: MODS file containing items to ingest
                required: true
                type: file
        responses:
          202:
            headers:
              location:
                description: URI pointing to the location of ingest status
          400:
            body:
              text/plain:
                example: "Cannot parse multiple files in a single request"
          500:
            body:
              text/plain:
      /status:
        /{id}:
          get:
            description: Status of a MODS ingest
            responses:
              200:
                body:
                  application/json:
                    example: !include examples/ingest_status_get.json
                    schema: ingest-status
              500:
                body:
                  text/plain:
